<?php
require './include/global.php';
require './include/validate.php';
require './include/all_left.php';
require_once './include/advisory_db.php';
include("FCKeditor/fckeditor.php") ;
$status = $_SESSION['status'];
if('Premium' == $status) {
	$jobcontact = array("1" => 'Candidates', '2' => 'Recruiters');
} else {
	$jobcontact     = array('2' => 'Network');
	$jobcontact_tip = array('2'=>'Check here to post this job to the network for view by other recruiter members.');
}
//print_r($_SESSION);
$smarty->compile_check = true;
include("./check/checkpostjob.php");
$_GET[id] = $_SESSION[uid];

$get = $_SESSION[usertype];

$smarty->display('header.tpl');
//'option'=>$jobcategory

if(empty($_POST)){
	if($_SESSION[usertype]=='recruiter'){
		$sql  = "SELECT * FROM pa_recuiter WHERE rc_id = '".$_SESSION[uid]."'";	
        $list = $DB->fetch_one_array($sql);
        $_POST[jo_copname]		  =  $list[rc_copname] ;
		$_POST[jo_copurl]		  =  $list[rc_website];
		$_POST[jo_priname]		  =  $list[rc_fname]." ".$list[rc_lname];
		$_POST[jo_priemail]		  =  $list[rc_email];
		$_POST[jo_priphone]		  =  $list[rc_phone];
		$_POST[jo_address]	      =	 $list[rc_address1];
		$_POST[jo_city]			  =  $list[rc_city];
		$_POST[jo_state]		  =  $list[rc_state];
		$_POST[jo_country]		  =  $list[rc_country];
		$_POST[jo_zip]			  =  $list[rc_zip];
		$_POST[jo_authorized]     =   "USA";
		$_POST[jo_category]       =  $list[rc_industry];
		$_POST[jo_positions]      = 1;
	}
	if($_SESSION[usertype]=='employer'){
		$sql  = "SELECT * FROM pa_employer WHERE ep_id = '".$_SESSION[uid]."'";	
        $list = $DB->fetch_one_array($sql);
        $_POST[jo_copname]		  =  $list[ep_copname] ;
		$_POST[jo_copurl]		  =  $list[ep_website];
		$_POST[jo_priname]		  =  $list[ep_fname]." ".$list[ep_lname];
		$_POST[jo_priemail]		  =  $list[ep_email];
		$_POST[jo_priphone]		  =  $list[ep_phone];
		$_POST[jo_address]	      =	 $list[ep_address1];
		$_POST[jo_city]			  =  $list[ep_city];
		$_POST[jo_state]		  =  $list[ep_state];
		$_POST[jo_country]		  =  $list[ep_country];
		$_POST[jo_zip]			  =  $list[ep_zip];
		$_POST[jo_authorized]     =   "USA";
		$_POST[jo_copculture]     =  $list[ep_CompCulture];
		$_POST[jo_copbenefit]	  =  $list[ep_CompBenefits];
		$_POST[jo_category]       =  $list[ep_industry];
		$_POST[jo_positions]      = 1;
	}
}
if($country==''){
$country = 211;
}

ob_clean();
ob_start();
$cpforms->formheader(array('title'=>'Job Record','name'=>'article','extra'=>'name="postjob"'));

echo '<div style="text-align:right;margin-top:-30px"> <input class="bginput button-secondary" type="submit" name="preview" value=" Preview " onclick=\'document.postjob.target="";document.postjob.action="previewjob.php"; this.form.submit();\' />
</div>';
$cpforms->makehidden(array('name'=>'action','value'=>'reg_job'));
$cpforms->gethightext(array('text'=>"Create Date",'value'=>date("m/d/Y",time()),'view'=>"1"));
$cpforms->longline(array('title'=>"Post Options"));
if($_SESSION[usertype]=='employer'){

$cpforms->getBoxes(array('one'=>1,'text'=>"Post To",'only'=>1,'name'=>"jo_contact[]",'view'=>"$view",'selected'=>empty($_POST[jo_contact])?array(2):$_POST[jo_contact],'option'=>$jobcontact_for_employer, 'notice_option'=>$jobcontact_tip_for_employer, 'text_tip'=>'Please select who may contact you regarding this job.'));

}else{

$defaultvalue = ('Premium' == $status)?array(4):array(4);
$disableArr = ('Premium' == $status)?array(4):array(4);
$_POST[jo_contact] = @array_unique(array_merge($_POST[jo_contact],array(4)));

//if standard user lock the 
$cpforms->getBoxes(array('one'=>1,'text'=>"Post To",'name'=>"jo_contact[]",'view'=>"$view",'selected'=>empty($_POST[jo_contact])?$defaultvalue:$_POST[jo_contact],'option'=>$jobcontact, 'notice_option'=>$jobcontact_tip, 'disableArr'=>$disableArr
//'text_tip'=>'Please select who may contact you regarding this job.'
));

}
if('Standard' == $status){ $jobCatOption = array('-- SELECT ALL --','2'=>'Job Split'); if(!$_POST[jo_cat]){$_POST[jo_cat]=2;}}
if($_POST[jo_cat] == 2) $smarty->assign('splitfee',1);
$cpforms->makeselect(array('one'=>1,'only'=>1,'text'=>"Job Category",'name'=>"jo_cat",'selected'=>"$_POST[jo_cat]",'view'=>"$view",'option'=> $jobCatOption, 'selectextra'=>' id="jo_cat" onchange="changeOptions(\'jobsplit\')" '));

$cpforms->maketextarea(array('text'=>"Job Split Fee ($ or %)",'name'=>"jo_bonus",'value'=>"$_POST[jo_bonus]",'view'=>"$view",icon=>"'Please indicate the service fee in US dollar, or the % payout for this job split.  Please include as much detail as possible.  Once posted, you cannot change this field. If you entered a wrong number, you must delete this job and create a new one.  (Example: The payout for this is 10% of annual salary, or $5,000 total fee).',WIDTH, 200, SHADOW, true", 'trId'=>'jobsplit'));


$cpforms->longline(array('title'=>"Your Company Information",'icon'=>"'Your company details here.', WIDTH, 200, SHADOW, true"));

$cpforms->gethightext(array('text'=>"Company Name",'name'=>"jo_copname",'only'=>1,'value'=>"$_POST[jo_copname]",'view'=>"$view",'icon'=>"'If you are independent and don\'t have a company name simply enter your name here.', WIDTH, 200, SHADOW, true"));
$cpforms->gethightext(array('text'=>"Company URL",'name'=>"jo_copurl",'value'=>"$_POST[jo_copurl]",'view'=>"$view",'icon'=>"' Leave blank if you don\'t have a website.', WIDTH, 200, SHADOW, true"));
$cpforms->gethightext(array('text'=>"Contact Name",'name'=>"jo_priname",'value'=>"$_POST[jo_priname]",'view'=>"$view",'icon'=>"'Your name will not be shown on jobs posted.', WIDTH, 200, SHADOW, true"));
$cpforms->gethightext(array('text'=>"Contact Email",'name'=>"jo_priemail",'value'=>"$_POST[jo_priemail]",'view'=>"$view",'icon'=>"'Your email will not be shown on jobs posted. This email will receive all applicants and messages for this job.', WIDTH, 200, SHADOW, true"));
$cpforms->gethightext(array('text'=>"Contact Phone",'name'=>"jo_priphone",'value'=>"$_POST[jo_priphone]",'view'=>"$view",'icon'=>"'This information is private and only viewable by you.', WIDTH, 200, SHADOW, true"));

$cpforms->longline(array('title'=>"Hiring Company Information (or your client)",'icon'=>"'If this is a job split, you can describe about your client company here.', WIDTH, 200, SHADOW, true"));

$_POST[jo_copculture] = $_POST[jo_copculture]?$_POST[jo_copculture]:"";
$cpforms->maketextarea(array('text'=>"About The Hiring Company",'name'=>"jo_copculture",'id'=>"jo_copculture",'value'=>"$_POST[jo_copculture]",'view'=>"$view",'icon'=>"' Include a description about the hiring company.  You may edit this later.', WIDTH, 200, SHADOW, true"));
$_POST[jo_copbenefit] = $_POST[jo_copbenefit]?$_POST[jo_copbenefit]:"";
$cpforms->maketextarea(array('text'=>"About The Hiring Manager",'name'=>"jo_copbenefit",'id'=>"jo_copbenefit",'value'=>"$_POST[jo_copbenefit]",'view'=>"$view",'icon'=>"' Include a description about the hiring manager.  You may edit this later.', WIDTH, 200, SHADOW, true"));

$cpforms->longline(array('title'=>"Job Information"));
$cpforms->gethightext(array('text'=>"Job Title",'name'=>"jo_title",'only'=>1,'value'=>"$_POST[jo_title]",'view'=>"$view"));
$cpforms->gethightext(array('text'=>"Job Valid By Date",'name'=>"jo_vdate",'value'=>"$_POST[jo_vdate]",'view'=>"$view",icon=>"' Please indicate by which date this job will be open.',WIDTH, 200, SHADOW, true"));

if(!$_POST[jo_status]){$_POST[jo_status]=1;}
$cpforms->makeselect(array('one'=>1,'text'=>"Job Fill Status",'only'=>1,'name'=>"jo_status",'view'=>"$view",'selected'=>"$_POST[jo_status]",'option'=> $jobfillstatus,icon=>"'Please indicate OPEN or On-Hold if you wish to receive messages.  When you change the status to CLOSED, you will stop receiving messages and candidates.  You may edit this status anytime.',WIDTH, 200, SHADOW, true"));
if(!$_POST[jo_priority]){$_POST[jo_priority]=2;}
$cpforms->makeselect(array('one'=>1,'text'=>"Job Priority",'name'=>"jo_priority",'selected'=>"$_POST[jo_priority]",'view'=>"$view",'option'=> $priority,'icon'=>"'You can indicate the priority status of this job.  This is a private field and is only viewable by you.',WIDTH, 200, SHADOW, true"));

if(!$_POST[jo_type]){$_POST[jo_type]=3;}
$cpforms->makeselect(array('one'=>1,'text'=>"Job Type",'only'=>1,'name'=>"jo_type",'view'=>"$view",'selected'=>"$_POST[jo_type]",'option'=>$jobtype));


$cpforms->makeselect(array('one'=>1,'text'=>"Job Industry",'name'=>"jo_category",'only'=>1,'selected'=>"$_POST[jo_category]",'view'=>"$view",'option'=> $jobcategory));
$cpforms->makeselect(array('one'=>1,'text'=>"Job Function",'name'=>"jo_function",'only'=>1,'selected'=>"$_POST[jo_function]",'view'=>"$view",'option'=> $jobfunction));
$cpforms->gethightext(array('text'=>"Internal Job Req#",'name'=>"jo_copreq",'value'=>"$_POST[jo_copreq]",'view'=>"$view",'icon'=>"'You can track your jobs by typing in an internal job req# or a client name.  This is a private field and only viewable by you.  You may edit this later.', WIDTH, 200, SHADOW, true"));
$cpforms->gethightext(array('text'=>"No. of Open Positions",'name'=>"jo_positions",'value'=>"$_POST[jo_positions]",'view'=>"$view"));
$cpforms->gethightext(array('text'=>"Compensation(US$)",'name'=>"jo_salrange", 'value'=>"$_POST[jo_salrange]",'view'=>"$view",'icon'=>"' Please indicate the pay range for this Job order.', WIDTH, 200, SHADOW, true"));

$cpforms->gethightext(array('text'=>"Work Address",'only'=>1,'name'=>"jo_address",'value'=>"$_POST[jo_address]",'view'=>"$view"));
$cpforms->gethightext(array('text'=>"City",'name'=>"jo_city",'only'=>1,'value'=>"$_POST[jo_city]",'view'=>"$view"));
$cpforms->makeselect(array('one'=>1,'text'=>"State/Region",'name'=>"jo_state",'only'=>1,'selected'=>"$_POST[jo_state]",'view'=>"$view",'option'=> $state));
$cpforms->makeselect(array('one'=>1,'text'=>"Country",'name'=>"jo_country",'only'=>1,'selected'=>"$_POST[jo_country]",'view'=>"$view",'option'=> $country));
$cpforms->gethightext(array('text'=>"Zip Code",'name'=>"jo_zip",'only'=>1,'value'=>"$_POST[jo_zip]",'view'=>"$view"));
$cpforms->makeselect(array('one'=>1,'text'=>"Will consider candidates how far from company location?",'name'=>"jo_howfar",'selected'=>"$_POST[jo_howfar]",'view'=>"$view",'option'=> $location));
$cpforms->makeselect(array('one'=>1,'text'=>"Travel Requirement",'name'=>"jo_jobtravel",'selected'=>"$_POST[jo_jobtravel]",'view'=>"$view",'option'=> $travel));
$cpforms->longline(array('title'=>"Job Qualifications"));

$cpforms->gethightext(array('text'=>"Minimum Education",'name'=>"jo_mer",'value'=>"$_POST[jo_mer]",'view'=>"$view"));
$cpforms->makeselect(array('one'=>1,'text'=>"Years of Relevant Work Experience",'name'=>"jo_myrwe",'selected'=>"$_POST[jo_myrwe]",'view'=>"$view",'option'=> $yearexp2));
$cpforms->makeselect(array('one'=>1,'text'=>"Years of People Management Experience",'name'=>"jo_ypme",'selected'=>"$_POST[jo_ypme]",'view'=>"$view",'option'=> $yearexp2));
$cpforms->makeselect(array('one'=>1,'text'=>"Years of Profit & Loss Responsibility",'name'=>"jo_yplr",'selected'=>"$_POST[jo_yplr]",'view'=>"$view",'option'=> $yearexp2));
$cpforms->gethightext(array('text'=>"Industry Licenses or Certifications",'name'=>"jo_license",'value'=>"$_POST[jo_license]",'view'=>"$view"));

$cpforms->gethightext(array('text'=>"Required Language Skills",'name'=>"jo_language",'value'=>"$_POST[jo_language]",'view'=>"$view"));
$cpforms->gethightext(array('text'=>"Authorized to Work in Locations",'name'=>"jo_authorized",'only'=>1,'value'=>"$_POST[jo_authorized]",'view'=>"$view",'icon'=>"'Please indicate the Country or Region where job candidates must have the authorization or permit to work.', WIDTH, 200, SHADOW, true"));
$cpforms->gethighradio(array('text'=>"Government Security Clearance",'name'=>"jo_usgsc",'selected'=>"$_POST[jo_usgsc]",'view'=>"$view",'icon'=>"'Indicate whether or not this job requires government clearance.', WIDTH, 200, SHADOW, true"));
$cpforms->makefck(array('text'=>"Job Description",'id'=>"jo_description",'name'=>"jo_description","only"=>1,'value'=>(($_POST[jo_description]==NULL || $_POST[jo_description] == "")?"":"$_POST[jo_description]"),'view'=>"$view",'icon'=>"'You may type-in or paste your job description here. Do not include your contact information.', WIDTH, 200, SHADOW, true"));
$cpforms->maketextarea(array('text'=>"Include a Public Note",'name'=>"jo_public",'id'=>"jo_public",'value'=>"$_POST[jo_public]",'view'=>"$view",'icon'=>"'Public note is visible to others. Do not include contact information.', WIDTH, 200, SHADOW, true"));
$cpforms->maketextarea(array('text'=>"Include a Private Note",'name'=>"jo_private",'id'=>"jo_private",'value'=>"$_POST[jo_private]",'view'=>"$view",'icon'=>"'Private note is only visible to you.', WIDTH, 200, SHADOW, true"));
//$cpforms->makePhpCaptcha(array('text'=>"Safe Code",'name'=>"imagecode",'value'=>"$_POST[imagecode]",'only'=>1));

echo '<tr class="tbhead">
<td colspan="2" align="center" bgcolor="#F0F0F0">
 <input class="bginput button-secondary" accesskey="y" type="button" name="aaaa" value=" Save and Post "  onclick=\'document.postjob.target=""; document.postjob.action="postjob.php";  this.form.submit()\'  /> 
 <input class="bginput button-secondary" type="button" name="preview" value=" Preview " onclick=\'document.postjob.target="";document.postjob.action="previewjob.php"; this.form.submit();\' />
 <input class="bginput button-secondary" accesskey="r" type="button" name="" value=" Cancel "  onclick="history.back(1)"  /> 
<br></td></tr></table></td></tr></form></table>';

$reg_data = ob_get_contents();
ob_end_clean();
$title   = "Add/Edit Job";
$content = "(<font color=red>*</font>=Required Field)";
$smarty->assign('title',$title);
$smarty->assign('content',$content);

if($err!=''){
$smarty->assign("err",$err);
}
$smarty->assign("reg",$reg_data);
$smarty->display('allleft.tpl');
$smarty->display('postjob.tpl');


$smarty->display('allright.tpl');
$smarty->display('footer.tpl');
?>
